//////////////////////////////////////////////////
// guiQtWindow.cpp
//
// Author: Tarik Belabbas et Adrien Hoffer
//////////////////////////////////////////////////

#include <QBoxLayout>
#include <QPushButton>
#include <QInputDialog>

#include "guiGLWidget.h"
#include "guiQtWindow.h"
#include "../gl/glRenderer.h"

using namespace std;

//------------------------------------------------------------------------------
guiQtWindow::guiQtWindow()
{
	m_mainLayout	= new QBoxLayout( QBoxLayout::TopToBottom );
	setLayout( m_mainLayout );
	setWindowTitle( tr( "IN55_project" ) );

	m_glWidget		= new guiGLWidget();
	m_mainLayout->addWidget( m_glWidget, Qt::AlignHCenter );

	// Button to load model
	m_addFireButton = new QPushButton( "Add fire" );
	QObject::connect( m_addFireButton, SIGNAL( clicked() ),
					this, SLOT( addFire() ) );
	m_addFireButton->setFixedWidth( 100 );
	m_addFireButton->setFixedHeight( 25 );
	m_mainLayout->addWidget( m_addFireButton, 0, Qt::AlignHCenter );
}

//------------------------------------------------------------------------------
guiQtWindow::~guiQtWindow()
{

}

//------------------------------------------------------------------------------
QSize guiQtWindow::minimumSizeHint() const
{
	return QSize( 50, 50 );
}

//------------------------------------------------------------------------------
void guiQtWindow::addFire()
{
	bool ok;
	float positionX = QInputDialog::getDouble( this,
			tr( "QInputDialog::getDouble()" ), tr( "x-coordinate:" ), 0,
			-10000, 10000, 2, &ok );

	if ( ok )
	{
		float positionY = QInputDialog::getDouble( this,
				tr( "QInputDialog::getDouble()" ), tr( "y-coordinate:" ), 0,
				-10000, 10000, 2, &ok );

		if ( ok )
		{
			float positionZ = QInputDialog::getDouble( this,
					tr( "QInputDialog::getDouble()" ), tr( "z-coordinate:" ),
					0, -10000, 10000, 2, &ok );

			if ( ok )
			{
				glRenderer::s_getInstance()->addFire( positionX, positionY, positionZ );
			}
		}
	}
}
